/**
 * 
 */
var oTable;
$(function(){
	//初始化
	initDataTable();
	
	$('#search').click(function(){
		oTable.ajax.reload();
	});
});

function initDataTable(departurecountry, arrivalcountry) {
	oTable = $('.example').DataTable({
		"dom": '<"top">rt<"bottom"ip><"clear">',
		"ajax": {
			"type": "POST",
			"url": "routelist.ajax",
			"data": function(d) {
				d.departurecountry = $('#departurecountry').val(),
				d.arrivalcountry = $('#arrivalcountry').val();
			}
		},
		"ordering": false,
		"aLengthMenu": [5, 10, 20, 40 ],
		"iDisplayLength" : 10,
		"oLanguage": {
			"sUrl": "static/js/datatable.cn.txt"
		},
		"aoColumns": [
			{"mDataProp":"id"},
			{"mDataProp":"departurecountry"},
			{"mDataProp":"departureairport"},
			{"mDataProp":"arrivalcountry"},
			{"mDataProp":"arrivalairport"},
			{"mDataProp":"triptype"},
			{"mDataProp":"status"},
			{"mDataProp":"temp"},
			{"mDataProp":"op"},
			{"mDataProp": "time"}
		],
		"columnDefs": [
           {
        	   "render": function (data, type, row) {
        		   if(row.triptype == "oneWay") {
        			   return '<span>单程&nbsp;&nbsp;</span>';
        		   } else {
        			   return '<span>往返&nbsp;&nbsp;</span>';
        		   }
        	   },
        	   
        	   "targets": 5
           },
           {
        	   "render": function (data, type, row) {
        		   if(row.status == "1") {
        			   return '<span>已开启&nbsp;&nbsp;</span><img class="showImg" alt="Brand" src="static/images/u165.png" width="40" height="40">';
        		   } else {
        			   return '<span>已关闭&nbsp;&nbsp;</span>';
        		   }
        	   },
        	   
        	   "targets": 6
           },
           {
        	   "render": function (data, type, row) {
        		   if(row.status == "1") {
        			   return '<a class="btn btn-warning" href="javascript:void(0);"  onclick="javascript:goSwitch(' + row.id + ',0)" title="关闭IPCC">关闭</a>';
        		   } else {
        			   return '<a class="btn btn-success" href="javascript:void(0);"  onclick="javascript:goSwitch(' + row.id + ',1)" title="开启IPCC">开启</a>';
        		   }
        	   },
        	   
        	   "targets": 7
           },
           {
               "render": function ( data, type, row ) {
            	   return '<input id="batch" name="batch" type="checkbox" value=' + row.id + ' />&nbsp;&nbsp;&nbsp;'+
            	   		  '<a class="btn btn-info" href="javascript:void(0);"  onclick="javascript:goEdit(' + row.id + ')" title="编辑">编辑</a>&nbsp;&nbsp;' +
            	   		  '<a class="btn btn-danger" href="javascript:void(0);"  onclick="javascript:delConfirm(' + row.id + ')" title="删除">删除</a>';
               },
               "targets": 8
           },
           {
               "targets": 9,
               "visible":false
           }
       ]
	});
}


//		"aoColumns": [
//			{ "data": "username" },
//			{ "data": "registerDate" },
//			{ "data": "rolename" },
//			{ "data": "state" },
//			{ "data": "op" }
//		],